package cn.tedu.egweibo5.common;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class JsonResult {
    @ApiModelProperty(value = "状态码",required = true)
    private Integer status;
    @ApiModelProperty(value = "状态信息",required = true)
    private String message;
    @ApiModelProperty(value = "返回数据",required = true)
    private Object data;

    public JsonResult(StatusCode statusCode) {
        this.status = statusCode.getState();
        this.message = statusCode.getMessage();
    }
    public JsonResult(StatusCode statusCode, Object data) {
        this.status = statusCode.getState();
        this.message = statusCode.getMessage();
        this.data = data;
    }

    public static JsonResult ok() {
        return new JsonResult(StatusCode.OPERATION_SUCCESS);
    }

    public static JsonResult ok(Object data) {
        return new JsonResult(StatusCode.OPERATION_SUCCESS, data);
    }
}
